package com.takanafu.haru.component{
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.ProgressEvent;
	
	import mx.events.FlexEvent;
	import mx.events.RSLEvent;
	import mx.preloaders.IPreloaderDisplay;

	public class StartupLoader extends Sprite implements IPreloaderDisplay{
		[Embed(source="assets/loading.swf")]
		private var _loading:Class;
		
		[Embed(source="assets/haru64.png")]
		private var _mainImage:Class;
		
		private var _timer:Loader;
		
		private var _stageWidth:Number = 500;
		private var _stageHeight:Number = 500;
		
		public function StartupLoader(){
			super();
		}
		
		public function initialize():void{
			var png:Bitmap = new _mainImage() as Bitmap;
			var swf:Sprite = new _loading() as Sprite;
			
			swf.scaleX = 0.4;
			swf.scaleY = 0.4;

			addChild(png);
			addChild(swf);
			png.x = this.stageWidth / 2 - png.width / 2;
			png.y = this.stageHeight / 2 - png.height;
			swf.x = this.stageWidth / 2 - swf.width * 0.4 / 2 + 5;
			swf.y = this.stageHeight / 2;// - png.height / 2;
		}
		
		public function get backgroundAlpha():Number{
			return 0;
		}
		
		public function set backgroundAlpha(value:Number):void{
		}
		
		public function get backgroundColor():uint{
			return 0xff0000;
		}
		
		public function set backgroundColor(value:uint):void{
		}
		
		public function get backgroundImage():Object{
			return null;
		}
		
		public function set backgroundImage(value:Object):void{
		}
		
		public function get backgroundSize():String{
			return null;
		}
		
		public function set backgroundSize(value:String):void{
		}
		
		private var _preloader:Sprite;
		public function set preloader(value:Sprite):void{
			this._preloader = value;
			
			value.addEventListener(ProgressEvent.PROGRESS,progressHandler);	
			value.addEventListener(Event.COMPLETE,completeHandler);
			value.addEventListener(RSLEvent.RSL_PROGRESS,rslProgressHandler);
			value.addEventListener(RSLEvent.RSL_COMPLETE,rslCompleteHandler);
			value.addEventListener(RSLEvent.RSL_ERROR,rslErrorHandler);
			value.addEventListener(FlexEvent.INIT_PROGRESS,initProgressHandler);
			value.addEventListener(FlexEvent.INIT_COMPLETE,initCompleteHandler);
		}
		protected function progressHandler(event:ProgressEvent):void{
			//trace("PROGRESS");
		}
		protected function completeHandler(event:Event):void{
			//trace("COMPLETE");
		}
		protected function rslProgressHandler(event:RSLEvent):void{
			//trace("RSL_PROGRESS");
		}
		protected function rslCompleteHandler(event:RSLEvent):void{
			//trace("RSL_COMPLETE");
		}
		protected function rslErrorHandler(event:RSLEvent):void{
			//trace("RSL_ERROR");
		}
		protected function initProgressHandler(event:Event):void{
			//trace("INIT_PROGRESS");
		}
		protected function initCompleteHandler(event:Event):void{
			//trace("INIT_COMPLETE");
			dispatchEvent(new Event(Event.COMPLETE));
		}

		
		
		
		public function get stageHeight():Number{
			return this._stageHeight;
		}
		
		public function set stageHeight(value:Number):void{
			this._stageHeight = value;
		}
		
		public function get stageWidth():Number{
			return this._stageWidth;
		}
		
		public function set stageWidth(value:Number):void{
			this._stageWidth = value;
		}
		
		/*
		override public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{
		}
		
		override public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void{
		}
		
		override public function dispatchEvent(event:Event):Boolean{
			return false;
		}
		
		override public function hasEventListener(type:String):Boolean{
			return false;
		}
		
		override public function willTrigger(type:String):Boolean{
			return false;
		}
		*/
	}
}